/* ==============================================================================
 * 创 建 者：lyt
 * 创建日期：2017-07-14	
 * 功能描述：商品分类

 * 修 改 人:
 * 修改时间:
 * 修改描述：
 * ==============================================================================*/
//修改登录密码
var editPasswordUrl = baseUrl+'MemberF/EditMemberLoginPwd';
//获取手机验证码
var getCodeUrl =  baseUrl+'/apiDefault/getTelphoneCode';
//会员信息获取
var getMemberViewUrl = baseUrl + 'MemberF/MemberView';
//修改安全密码
var editPasswordUrl1 = baseUrl+'MemberF/EditMemberSecondPwd';

var vu;
$(function(){
	initVue();
});

function initVue(){
	vu = new Vue({
		el : '#content',
		data : {
		    oldPwd: '',
			newPwd : '',
			confirmPwd : '',//确认密码
			
			oldPwd1: '',
			newPwd1 : '',
			confirmPwd1 : '',//确认密码
			
			member : '',
		},
		mounted: function() {
			this.getMemberView();
		},
		methods : {
			getMemberView : getMemberView,
			editPassword : function(){
			    if (!this.oldPwd) {
					mui.toast('请输入原密码！');
					return ;
				}
				if(!this.newPwd){
					mui.toast('请输入新密码！');
					return ;
				}
				if(!this.confirmPwd){
					mui.toast('请再次输入新密码！');
					return ;
				}
				if(this.newPwd != this.confirmPwd){
					mui.toast('两次密码不一致，请重新输入！');
					return ;
				}
				var data = {
					OldPassword : this.oldPwd,
					NewPassword : this.newPwd,
					ConNewPassword : this.confirmPwd,
				};
				common.post(editPasswordUrl,data,'json',function(r){
					if(r.ErrorCode==0){
						mui.toast('修改成功');
						vu.oldPwd = '';
						vu.newPwd = '';
						vu.confirmPwd = '';
//						location.href='index.html'
					}else{
						mui.toast(r.ErrorMsg);
					}
				})
			},
			editPassword1 : function(){
			    if (!this.oldPwd1) {
					mui.toast('请输入原密码！');
					return ;
				}
				if(!this.newPwd1){
					mui.toast('请输入新密码！');
					return ;
				}
				if(!this.confirmPwd1){
					mui.toast('请再次输入新密码！');
					return ;
				}
				if(this.newPwd1 != this.confirmPwd1){
					mui.toast('两次密码不一致，请重新输入！');
					return ;
				}
				var data = {
					OldPassword : this.oldPwd1,
					NewPassword : this.newPwd1,
					ConNewPassword : this.confirmPwd1,
				};
				common.post(editPasswordUrl1,data,'json',function(r){
					if(r.ErrorCode==0){
						mui.toast('修改成功');
						vu.oldPwd1 = '';
						vu.newPwd1 = '';
						vu.confirmPwd1 = '';
//						location.href='index.html'
					}else{
						mui.toast(r.ErrorMsg);
					}
				})
			}
		}
	})
}

function getMemberView(){
	common.get(getMemberViewUrl,{},'json',function(r){
		if(r.ErrorCode==0){
			vu.member = r.Data.member;
		}else{
			mui.toast(r.ErrorMsg);
		}
	})
}